//
//  UIImageView+WebImage.m
//  JackToolsBox
//
//  Created by Jack Xue on 2019/12/3.
//  Copyright © 2019 Jack Xue. All rights reserved.
//

#import "UIImageView+WebImage.h"
#import "JackWebImageManager.h"

@implementation UIImageView (WebImage)
#pragma mark - 给UIImageView赋值image
-(void)setWebImageWithUrl:(NSString*)urlString placeholder:(UIImage*)placeholderImage{
    [self setWebImageWithUrl:urlString placeholder:placeholderImage taskCompletion:^(NSError * _Nonnull err) {
        //doing nothing here
    }];
}

-(void)setWebImageWithUrl:(NSString*)urlString{
    [self setWebImageWithUrl:urlString placeholder:[UIImage new] taskCompletion:^(NSError * _Nonnull err) {
        //doing nothing here
    }];
    
}

-(void)setWebImageWithUrl:(NSString*)urlString placeholder:(UIImage*)placeholderImage taskCompletion:(void(^)(NSError *err))completion{
    //1.先给UIImageView赋值placeholder
    self.image = placeholderImage;
    //2.将任务转发给manager处理
    [[JackWebImageManager sharedManager]sendImgeViewToManager:self url:urlString completion:^(NSError * _Nullable err) {
        if (err && completion) {
            completion(err);
        }
    }];
}

@end
